package com.bjsxt.service.impl;

import com.bjsxt.exception.MyException;
import com.bjsxt.mapper.UserMapper;
import com.bjsxt.pojo.Users;
import com.bjsxt.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;


    @Override
    public Users userlogin(String username, String userpwd) {
        Users users = userMapper.selectUserByName(username);
        if(users == null){
            //用户不存在
            throw new MyException("用户名不存在");
        }
        if(!users.getUserpwd().equals(userpwd)){
            //密码有误
            throw new MyException("密码有误");
        }
        return users;
    }
}
